#include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 1e3 + 10;
PII arr[N];
int l;
int cmp(PII a, PII b)
{
	return a.first < b.first;
}
int main()
{
	cin >> l;
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		arr[i] = { x,y };
	}
	sort(arr, arr + q ,cmp);
	int st = 0;
	int ed = -1;
	int ans = 0;
	for (int i = 0; i < q; i++) {
		int x = arr[i].x;
		int y = arr[i].y;
		if (ed < x) {
			ans += ed - st + 1;
			st = x;
			ed = y;
		}
		else {
			ed = max(ed, y);
		}
	}
	ans += ed - st + 1;
	cout << l - ans + 1<< endl;
	return 0;
}